<?php

if(version_compare(PHP_VERSION,'7.0.0','<'))  die('require PHP > 7.0.0 !');

  $phpv = phpversion();
  $root = __DIR__;
  $sp_os = PHP_OS;
  $sp_gd = gdversion();
  $sp_server = $_SERVER['SERVER_SOFTWARE'];
  $sp_host = (empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR']);
  $sp_name = $_SERVER['SERVER_NAME'];
  $sp_max_execution_time = ini_get('max_execution_time');
  $sp_allow_reference = (ini_get('allow_call_time_pass_reference') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_allow_url_fopen = (ini_get('allow_url_fopen') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_safe_mode = (ini_get('safe_mode') ? '<font color=red>[×]On</font>' : '<font color=green>[√]Off</font>');
  $sp_gd = ($sp_gd>0 ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_mysql = (extension_loaded('mysqli') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_mbstring = (extension_loaded('mbstring') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_pdo_mysql = (extension_loaded('pdo_mysql') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_openssl = (extension_loaded('openssl') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_fileinfo = (extension_loaded('fileinfo') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_PDO = (extension_loaded('PDO') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_tokenizer = (extension_loaded('tokenizer') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_xml = (extension_loaded('xml') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');
  $sp_curl = (extension_loaded('curl') ? '<font color=green>[√]On</font>' : '<font color=red>[×]Off</font>');


  if($sp_mysql=='<font color=red>[×]Off</font>')
    $sp_mysql_err = TRUE;
  else
    $sp_mysql_err = FALSE;

  $sp_testdirs = array(
    '/',
    '/plus/*',
    '/dede/*',
    '/data/*',
    '/a/*',
    '/install',
    '/special',
    '/uploads/*'
  );
$fulld = $root.'/../storage/logs/lumen.log';

$rsta = (is_readable($fulld) ? '<font color=green>[√]读</font>' : '<font color=red>[×]读</font>');
$wsta = (is_writable  ($fulld) ? '<font color=green>[√]写</font>' : '<font color=red>[×]写</font>');


function gdversion()
{
  //没启用php.ini函数的情况下如果有GD默认视作2.0以上版本
  if(!function_exists('phpinfo'))
  {
    if(function_exists('imagecreate')) return '2.0';
    else return 0;
  }
  else
  {
    ob_start();
    phpinfo(8);
    $module_info = ob_get_contents();
    ob_end_clean();
    if(preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info,$matches)) {   $gdversion_h = $matches[1];  }
    else {  $gdversion_h = 0; }
    return $gdversion_h;
  }
}


function TestWrite($d)
{
  $tfile = '_dedet.txt';
  $d = preg_replace("#\/$#", '', $d);
  $fp = @fopen($d.'/'.$tfile,'w');
  if(!$fp) return false;
  else
  {
    fclose($fp);
    $rs = @unlink($d.'/'.$tfile);
    if($rs) return true;
    else return false;
  }
}

echo "
  <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>环境检测</title>
<link href='css/style.css' rel='stylesheet' type='text/css' />
</head>

<body>


<div class='main'>
  <div class='pright'>
    <div class='pr-title'><h3>服务器信息</h3></div>
    <table width='726' border='0' align='center' cellpadding='0' cellspacing='0' class='twbox'>
      <tr>
        <th width='300' align='center'><strong>参数</strong></th>
        <th width='424'><strong>值</strong></th>
      </tr>
      <tr>
        <td><strong>服务器域名</strong></td>
        <td>$sp_name</td>
      </tr>
      <tr>
        <td><strong>服务器操作系统</strong></td>
        <td>$sp_os</td>
      </tr>
      <tr>
        <td><strong>服务器解译引擎</strong></td>
        <td>$sp_server</td>
      </tr>
      <tr>
        <td><strong>PHP版本</strong></td>
        <td> $phpv </td>
      </tr>
      <tr>
        <td><strong>系统安装目录</strong></td>
        <td>$root</td>
      </tr>
    </table>
    <div class='pr-title'><h3>系统环境检测</h3></div>
    <div style='padding:2px 8px 0px; line-height:33px; height:23px; overflow:hidden; color:#666;'>
      系统环境要求必须满足下列所有条件，否则系统或系统部份功能将无法使用。
    </div>
    <table width='726' border='0' align='center' cellpadding='0' cellspacing='0' class='twbox'>
      <tr>
        <th width='200' align='center'><strong>需开启的变量或函数</strong></th>
        <th width='80'><strong>要求</strong></th>
        <th width='400'><strong>实际状态及建议</strong></th>
      </tr>
      <tr>
        <td>allow_url_fopen</td>
        <td align='center'>On </td>
        <td>$sp_allow_url_fopen <small>(不符合要求将导致采集、远程资料本地化等功能无法应用)</small></td>
      </tr>
      <tr>
        <td>safe_mode</td>
        <td align='center'>Off</td>
        <td>$sp_safe_mode <small>(本系统不支持在<span class='STYLE2'>非win主机的安全模式</span>下运行)</small></td>
      </tr>

      <tr>
        <td>GD 支持 </td>
        <td align='center'>On</td>
        <td>$sp_gd <small>(不支持将导致与图片相关的大多数功能无法使用或引发警告)</small></td>
      </tr>
      <tr>
        <td>MySQL 支持</td>
        <td align='center'>On</td>
        <td>$sp_mysql <small>(不支持无法使用本系统)</small></td>
      </tr>
            <tr>
        <td>PDO 支持</td>
        <td align='center'>On</td>
        <td>$sp_PDO <small>(不支持无法使用本系统)</small></td>
      </tr>
       <tr>
        <td>PDO_MySQL 支持</td>
        <td align='center'>On</td>
        <td>$sp_pdo_mysql <small>(不支持无法使用本系统)</small></td>
      </tr>
      <tr>
        <td>mbstring 支持</td>
        <td align='center'>On</td>
        <td>$sp_mbstring <small>(不支持无法使用本系统)</small></td>
      </tr>
      <tr>
        <td>openssl 支持</td>
        <td align='center'>On</td>
        <td>$sp_openssl <small>(不支持无法使用本系统)</small></td>
      </tr>
      <tr>
        <td>curl 支持</td>
        <td align='center'>On</td>
        <td>$sp_curl <small>(不支持无法使用本系统)</small></td>
      </tr>
      <tr>
        <td>fileinfo 支持</td>
        <td align='center'>On</td>
        <td>$sp_fileinfo <small>(不支持无法使用本系统)</small></td>
      </tr>
        <td>tokenizer 支持</td>
        <td align='center'>On</td>
        <td>$sp_tokenizer <small>(不支持无法使用本系统)</small></td>
      </tr>
      <tr>
        <td>xml 支持</td>
        <td align='center'>On</td>
        <td>$sp_xml <small>(不支持无法使用本系统)</small></td>
      </tr>
    </table>

    <div class='pr-title'><h3>目录权限检测</h3></div>
    <div style='padding:2px 8px 0px; line-height:33px; height:23px; overflow:hidden; color:#666;'>
      系统要求必须满足下列所有的目录权限全部可读写的需求才能使用，其它应用目录可安装后在管理后台检测。
    </div>
    <table width='726' border='0' align='center' cellpadding='0' cellspacing='0' class='twbox'>
      <tr>
        <th width='300' align='center'><strong>目录名</strong></th>
        <th width='212'><strong>读取权限</strong></th>
        <th width='212'><strong>写入权限</strong></th>
      </tr>
      <tr>
        <th width='300' align='center'><strong>storage/logs</strong></th>
        
        <td>$rsta</td><td>$wsta</td>
      </tr>
    </table>


  </div>
</div>

<div class='foot'>

</div>

</body>
</html>
";

